/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kreig133.spine.simplemodel;

import com.kreig133.spine.abstractmodel.AbstractSpine;
import com.kreig133.spine.abstractmodel.AbstractVelebra;

/**
 *
 * @author C.C.-fag
 */
public class Basement  extends AbstractVelebra implements com.kreig133.spine.interfaces.Basement{

    @SuppressWarnings("FieldNameHidesFieldInSuperclass")
    SimpleState smState;

    public Basement(AbstractSpine spine){
        this.spine = spine;
    }
    @Override
    public void nextState() {
    }

    public SimpleState getState() {
        return smState;
    }

    
    /**
     * Устанавливает состояние основания.
     * @param st 
     */
    public void setState(SimpleState st){
        smState = st;
    }
    
    @Override
    public void run() {
//        Thread.currentThread().setDaemon(true);
        while(true){
            synchronized(spine.forSynchronize){
//                System.out.println("Фигня война"+Thread.currentThread().getName());
                spine.addState(this, smState);
                
                try {
                    spine.forSynchronize.wait();
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
              
            }
        }
    }
}
